<!DOCTYPE html>
<html>
  <head>
    <title>ClientB</title>
  </head>
  <body>
    <h1>ClientB</h1>
    <ul>
      <button onclick="setCookies()">setCookies</button>
      <button onclick="test()">test</button>
    </ul>
  <script type="text/javascript">
    function setCookies() {
      fetch("http://localhost:3000/server/login", {
        method: "post",
        credentials: "include",
        body: {}
      }).then(res => {
        alert("设置成功"+res)
      }).catch(err => {
        alert("设置失败"+res)
      })
    }
    function test() {
      fetch("http://localhost:3000/server/list", {
        method: "get",
        //限制请求只能使用
        //请求方法(get/post/put)和
        //请求头(accept/accept-language/content-language/content-type),
        //既只能访问后台开放的端口，因为没办法设置后端需要鉴权的请求头
        // mode: "no-cors",
        credentials: "include"
      }).then(res => {
        alert("设置成功"+res)
      }).catch(err => {
        alert("设置失败"+res)
      })
    }
  </script>
  </body>
</html>
